import java.lang.reflect.Array;
import java.util.Arrays;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: LIUYANJIAO
 * Date: 2024-06-02
 * Time: 12:12
 */
public class Main {
    public int lengthOfLongestSubstring(String s) {
        

    }
    public static void merge(int[] nums1, int m, int[] nums2, int n) {
        if(m==0) {
            System.out.println(Arrays.toString(nums2));
             return;
        }
        if(n==0)
        {
            System.out.println(Arrays.toString(nums1));
            return;
        }for(int i=m;i<m+n;i++){
            nums1[i]=nums2[i-m];
        }
        Arrays.sort(nums1);
        System.out.println(Arrays.toString(nums1));


    }

    public static void main3(String[] args) {
        int[]nums1={0};
        int[]nums2={1};

        merge(nums1,0,nums2,1);
    }
    public int climbStairs(int n) {
        //爬楼梯 斐波那契
        int[]bp=new int[n+1];
        //初始化
        bp[0]=bp[1]=1;
        for(int i=2;i<=n;i++){
            bp[i]=bp[i-1]+bp[i-2];
        }
        return bp[n];

    }
    public static String addBinary(String a, String b) {
        int m=a.length()-1;
        int n=b.length()-1;
        StringBuilder st=new StringBuilder();
        int carry=0;
        while(m>=0||n>=0||carry==1){
            if(m>=0){
                carry+=a.charAt(m--)-'0';
            }
            if(n>=0){
                carry+=b.charAt(n--)-'0';
            }
            st.append(carry%2);
            carry/=2;
        }
        return st.reverse().toString();
    }
    public static String addBinary1(String a, String b) {
        //二进制(超时)
        int c=Integer.valueOf(a);
        int d=Integer.valueOf(b);
        int m=0;
        int n=0;
        int i=0;
        while(c!=0){
            m+=Math.pow(2,i++)*(c%10);
            c/=10;
        }
        i=0;
        while(d!=0){
            n+=Math.pow(2,i++)*(d%10);
            d/=10;
        }
        int r=m+n;
        StringBuilder st=new StringBuilder();
        if(r==0) return "0";
        while(r!=0){
            st.insert(0,r%2);
            r/=2;
        }
        return st.toString();

    }

    public static void main2(String[] args) {
        System.out.println(addBinary("11","1"));
    }
    public static int[] plusOne(int[] digits) {
       //讨论情况
        for (int i = digits.length-1; i >=0; i--) {
            if(digits[i]<9){
                digits[i]++;
                return digits;
            }digits[i]=0;
        }int[] arr=new int[digits.length+1];
        arr[0]=1;
        for (int i = 1; i < arr.length; i++) {
            arr[i]=digits[i-1];
        }
        return arr;


    }
    public int lengthOfLastWord(String s) {
        String[] arr=s.split(" ");//将字符串分割为字符数组
        return arr[arr.length-1].length();
    }
    public static void main1(String[] args) {
        int[]arr={9};
        int[]arr1=plusOne(arr);
        System.out.println(Arrays.toString(arr1));

    }
}